From: Niklas Laxström Date: Sun, 6 May 2007 20:52:03 +0000 (+0000) Subject: * Polishing and documentation X-Git-Tag: 1.31.0-rc.0~53047 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=4ca6bed03a73ebcf8fff3f7f9aa10d7705e90ca6;p=lhc%2Fweb%2Fwiklou.git * Polishing and documentation --- diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index f73c118e95..a5436d533c 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -441,12 +441,17 @@ class PreferencesForm { return "$td1$td2"; } - function tableRow( $td1, $td2, $td3 = null ) { - global $wgLang; + /** + * Helper function for user information panel + * @param $td1 label for an item + * @param $td2 item or null + * @param $td3 optional help or null + * @return xhtml block + */ + function tableRow( $td1, $td2 = null, $td3 = null ) { + global $wgContLang; - $a1 = $a2 = array(); - $a1['align'] = $wgLang->isRtl() ? 'left' : 'right'; - $a2['align'] = $wgLang->isRtl() ? 'right' : 'left'; + $align['align'] = $wgContLang->isRtl() ? 'right' : 'left'; if ( is_null( $td3 ) ) { $td3 = ''; @@ -456,8 +461,13 @@ class PreferencesForm { ); } - $td1 = Xml::tags( 'td', $a2, $td1 ); - $td2 = Xml::tags( 'td', $a2, $td2 ); + if ( is_null( $td2 ) ) { + $td1 = Xml::tags( 'td', $align + array( 'colspan' => '2' ), $td1 ); + $td2 = ''; + } else { + $td1 = Xml::tags( 'td', $align, $td1 ); + $td2 = Xml::tags( 'td', $align, $td2 ); + } return Xml::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n"; @@ -544,17 +554,12 @@ class PreferencesForm { $wgOut->addHTML( "
" ); # User data - # $wgOut->addHTML( Xml::openElement( 'fieldset ' ) . Xml::element( 'legend', null, wfMsg('prefs-personal') ) . Xml::openElement( 'table' ) . - Xml::tags( 'tr', null, - Xml::tags( 'td', array( 'colspan' => '2' ), - Xml::element( 'h1', null, wfMsg( 'prefs-personal' ) ) - ) - ) + $this->tableRow( Xml::element( 'h2', null, wfMsg( 'prefs-personal' ) ) ) ); $userInformationHtml = @@ -605,12 +610,7 @@ class PreferencesForm { Xml::input( 'wpNick', 25, $this->mNick, array( 'id' => 'wpNick' ) ) ) . $invalidSig . - # FIXME: The part should be where the   is, getToggle() needs - # to be changed to out return its output in two parts. -ævar - $this->tableRow( - ' ', - $this->getToggle( 'fancysig' ) - ) + $this->tableRow( ' ', $this->getToggle( 'fancysig' ) ) ); list( $lsLabel, $lsSelect) = Xml::languageSelector( $this->mUserLanguage ); @@ -654,11 +654,7 @@ class PreferencesForm { # Password if( $wgAuth->allowPasswordChange() ) { $wgOut->addHTML( - Xml::tags( 'tr', null, - Xml::tags( 'td', array( 'colspan' => '2' ), - Xml::element( 'h1', null, wfMsg( 'changepassword' ) ) - ) - ) . + $this->tableRow( Xml::element( 'h2', null, wfMsg( 'changepassword' ) ) ) . $this->tableRow( Xml::label( wfMsg( 'oldpassword' ), 'wpOldpass' ), Xml::input( 'wpOldpass', 25, $this->mOldpass, array( 'id' => 'wpOldpass' ) ) @@ -693,31 +689,25 @@ class PreferencesForm { $wgOut->addHTML( - Xml::tags( 'tr', null, - Xml::tags( 'td', array( 'colspan' => '2' ), - Xml::element( 'h1', null, wfMsg( 'email' ) ) - ) - ) . - Xml::tags( 'tr', null, - Xml::tags( 'td', array( 'colspan' => '2' ), - $emailauthenticated. - $enotifrevealaddr. - $enotifwatchlistpages. - $enotifusertalkpages. - $enotifminoredits. - $moreEmail. - $this->getToggle( 'ccmeonemails' ) - ) + $this->tableRow( Xml::element( 'h2', null, wfMsg( 'email' ) ) ) . + $this->tableRow( + $emailauthenticated. + $enotifrevealaddr. + $enotifwatchlistpages. + $enotifusertalkpages. + $enotifminoredits. + $moreEmail. + $this->getToggle( 'ccmeonemails' ) ) ); } + # $wgOut->addHTML( Xml::closeElement( 'table' ) . Xml::closeElement( 'fieldset' ) ); - # # Quickbar # diff --git a/includes/Xml.php b/includes/Xml.php index 2c7a82bea2..1d38c34e7a 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -110,6 +110,12 @@ class Xml { return $s; } + /** + * + * @param $language The language code of the selected language + * @param $customisedOnly If true only languages which have some content are listed + * @return array of label and select + */ public static function languageSelector( $selected, $customisedOnly = true ) { global $wgContLanguageCode; /** @@ -127,11 +133,10 @@ class Xml { * Otherwise, no default is selected and the user ends up * with an Afrikaans interface since it's first in the list. */ - $selectedLang = isset( $languages[$selected] ) ? $selected : $wgContLanguageCode; + $selected = isset( $languages[$selected] ) ? $selected : $wgContLanguageCode; $options = "\n"; foreach( $languages as $code => $name ) { - $selected = ($code == $selectedLang); - $options .= Xml::option( "$code - $name", $code, $selected ) . "\n"; + $options .= Xml::option( "$code - $name", $code, ($code == $selected) ) . "\n"; } return array(